package com.innovations.inn.service.impl;

import java.util.List;

import com.innovations.common.utils.uuid.IdGeneratorSnowflake;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.innovations.inn.mapper.ResearchOutcomesCollectMapper;
import com.innovations.inn.domain.ResearchOutcomesCollect;
import com.innovations.inn.service.IResearchOutcomesCollectService;

/**
 * 科研成果收藏Service业务层处理
 * 
 * @author dp
 * @date 2024-08-09
 */
@Service
public class ResearchOutcomesCollectServiceImpl implements IResearchOutcomesCollectService 
{
    @Autowired
    private ResearchOutcomesCollectMapper researchOutcomesCollectMapper;
    @Autowired
    IdGeneratorSnowflake idGeneratorSnowflake;

    /**
     * 查询科研成果收藏
     * 
     * @param collectId 科研成果收藏主键
     * @return 科研成果收藏
     */
    @Override
    public ResearchOutcomesCollect selectResearchOutcomesCollectByCollectId(Long collectId)
    {
        return researchOutcomesCollectMapper.selectResearchOutcomesCollectByCollectId(collectId);
    }

    /**
     * 查询科研成果收藏列表
     * 
     * @param researchOutcomesCollect 科研成果收藏
     * @return 科研成果收藏
     */
    @Override
    public List<ResearchOutcomesCollect> selectResearchOutcomesCollectList(ResearchOutcomesCollect researchOutcomesCollect)
    {
        return researchOutcomesCollectMapper.selectResearchOutcomesCollectList(researchOutcomesCollect);
    }

    /**
     * 新增科研成果收藏
     * 
     * @param researchOutcomesCollect 科研成果收藏
     * @return 结果
     */
    @Override
    public int insertResearchOutcomesCollect(ResearchOutcomesCollect researchOutcomesCollect)
    {
        return researchOutcomesCollectMapper.insertResearchOutcomesCollect(researchOutcomesCollect);
    }

    /**
     * 修改科研成果收藏
     * 
     * @param researchOutcomesCollect 科研成果收藏
     * @return 结果
     */
    @Override
    public int updateResearchOutcomesCollect(ResearchOutcomesCollect researchOutcomesCollect)
    {
        return researchOutcomesCollectMapper.updateResearchOutcomesCollect(researchOutcomesCollect);
    }

    /**
     * 批量删除科研成果收藏
     * 
     * @param collectIds 需要删除的科研成果收藏主键
     * @return 结果
     */
    @Override
    public int deleteResearchOutcomesCollectByCollectIds(Long[] collectIds)
    {
        return researchOutcomesCollectMapper.deleteResearchOutcomesCollectByCollectIds(collectIds);
    }

    /**
     * 删除科研成果收藏信息
     * 
     * @param collectId 科研成果收藏主键
     * @return 结果
     */
    @Override
    public int deleteResearchOutcomesCollectByCollectId(Long collectId)
    {
        return researchOutcomesCollectMapper.deleteResearchOutcomesCollectByCollectId(collectId);
    }

    /**
     * 实体数据补全
     *
     * @param researchOutcomesCollect 实体
     * @param userId       用户id
     * @param crateType    创建类型 1：新增 2：修改
     */
    @Override
    public void completeData(ResearchOutcomesCollect researchOutcomesCollect, Long userId, Integer crateType) {
        //主键
        if (researchOutcomesCollect.getCollectId() == null || "".equals(researchOutcomesCollect.getCollectId())) {
            researchOutcomesCollect.setCollectId(idGeneratorSnowflake.nextId());
        }
//        //创建人、创建时间
//        if (crateType == 1) {
//            if (researchOutcomesCollect.getCreateBy() == null || "".equals(researchOutcomesCollect.getCreateBy())) {
//                researchOutcomesCollect.setCreateBy(userId);
//            }
//            if (researchOutcomesCollect.getCreateTime() == null) {
//                researchOutcomesCollect.setCreateTime(DateUtils.getNowDate());
//            }
//        }
//        //修改人
//        if (researchOutcomesCollect.getModifyBy() == null) {
//            researchOutcomesCollect.setModifyBy(userId);
//        }
//        //修改时间
//        if (researchOutcomesCollect.getModifyTime() == null) {
//            researchOutcomesCollect.setModifyTime(DateUtils.getNowDate());
//        }
    }
}
